package algotithm.acwing.test800;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author zhouyanxiang
 * @Date 2021-01-2021/1/6-17:14
 */
public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] str = reader.readLine().split(" ");
        int n = Integer.parseInt(str[0]);
        int m = Integer.parseInt(str[1]);
        int x = Integer.parseInt(str[2]);
        int[] arr = new int[n];
        int[] num = new int[m];
        String[] s1 = reader.readLine().split(" ");
        String[] s2 = reader.readLine().split(" ");
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(s1[i]);
        }
        for (int i = 0; i < m; i++) {
            num[i] = Integer.parseInt(s2[i]);
        }
        reader.close();
        for (int i = 0, j = num.length - 1; i < n; i++) {
            while (j > 0 && arr[i] + num[j] > x) {
                j--;
            }
            if (arr[i] + num[j] == x) {
                System.out.println(i + " " + j);
                break;
            }
        }
    }

}
